home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / quotemkr / slctntls.c < prev    next >
Encoding:
Text File  |  1993-06-15  |  13.1 KB  |  314 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/QuoteMaker/RCS/selectionUtils.c,v 2.11 92/05/14 15:42:36 drapeau Exp $ */
  25. /* $Log:    selectionUtils.c,v $
  26.  * Revision 2.11  92/05/14  15:42:36  drapeau
  27.  * * Updated copyright information.
  28.  * * Removed SemiHighlightSelection() as it is no longer used.
  29.  * * Removed inclusion of "gdd.h" file as it is not used by
  30.  *   this file.
  31.  * 
  32.  * Revision 2.10  91/12/31  18:45:24  drapeau
  33.  * Removed the inclusion of string.h, since XView will include the
  34.  * appropriate definitions.
  35.  * 
  36.  * Revision 2.0  91/09/30  15:02:45  derek
  37.  * Version number changed to 2.0.
  38.  * 
  39.  * Revision 1.37  91/09/15  20:06:34  derek
  40.  * The following things are done:
  41.  * 1.      The foreground of mainTextPane and Quote Window are set to be black.
  42.  *         Also, the color of all the text fields are set to black.
  43.  * 2.      Now the quoted text will be shown directly on the Quote Window
  44.  *         when a panel-item selection is made.  The text will also be shown
  45.  *         while the author is highlighting a selection in the text window.
  46.  * 3.      The inconsistency problem regarding text selection is being taken
  47.  *         care of.  When the mouse cursor re-enters the text window,
  48.  *         the selection will be highlighted again.
  49.  * 4.      When the play button is pressed, the text currently selected
  50.  *         in the text window (rather than the text initially associated
  51.  *         with the edit) will be displayed.
  52.  * 5.      The name of the menu_option "Show Quote Window Specifications panel"
  53.  *         is shortened to be "Quote Window Options ..."
  54.  * 6.      A notify_interpose_destroy_func() is being added to fix the bug
  55.  *         that QuoteMaker might exit without killing the Quote Window (which
  56.  *         is also a base window).
  57.  * 7.      When a different font family or font style is selected, the change
  58.  *         will be automatically be reflected on the Quote Window (without the
  59.  *         need to "play" the edit in order to verify the font).  For font
  60.  *         size, the change will be reflected when either a return character is
  61.  *         entered at the text field or when one of those numeric "arrows"
  62.  *         are pressed.
  63.  * 8.      The play button will now flash when an edit is being played.
  64.  *         Pause button will also glow when playing is paused.
  65.  * 9.      In the course of playing, when another edit is selected,
  66.  *         the playing will be stopped.
  67.  * 10.     I have used Saber to clean up the code.
  68.  * 11.     The left-over "NewEditListPopUp" window is removed.
  69.  * 12.     The bug that when quote window is iconified, it wont be un-iconified
  70.  *         when the edit is played in timeline, is fixed.
  71.  * 13.     The DurationEstimate function is changed so that it no longer
  72.  *         needs an edit to be selected first.  It will take textWindowStart
  73.  *         and textWindowEnd directly as input parameters.
  74.  * 
  75.  * 
  76.  * 
  77.  * Revision 1.36  91/09/05  15:48:05  derek
  78.  * The following changes are made:
  79.  * 1.      The name "Quoted Text Window" has been changed to "Quote Window"
  80.  *         in the app.
  81.  * 2.      ShowApplication() and HideApplication() is changed because of the
  82.  *         the change of quote window from a popup to a basewindow.
  83.  * 3.      The QuitProc of QuoteMaker is fixed so that the quote window,
  84.  *         as a base window, will be destroyed separately.
  85.  * 4.      Now hitting return in the label field will not result in adding
  86.  *         a new edit.
  87.  * 5.      Copyright messages are included in front of every .h and .c file.
  88.  * 6.      The scrollbar and the footer of the Quote Window are hidden.
  89.  * 7.      I have changed the include openpanel.h statement in QuoteMaker.c
  90.  *         to include Browse.h.
  91.  * 8.      The delete bug corresponding to the change that the panel-list
  92.  *         must have a choice -- is fixed.  Also, the corresponding bug
  93.  *         for deleteAll is also fixed.
  94.  * 9.      Now, deleteAll and deletion of the last item in Panel_list
  95.  *         will cause the panel-list to be destroyed and a new one will
  96.  *         be created.
  97.  * 10.     GetOpt files have been removed from the directory.  Corresponding
  98.  *         changes are made.
  99.  * 11.     The start and end byte fields are removed from the main panel.
  100.  * 12.     I have put iconify, hide and show quote window to be buttons
  101.  *         instead of menu options.
  102.  * 13.     I have removed the PreviewPanelPopup and incorporated its features into
  103.  *         the main panel.  The three buttons:  pause, play and stop and
  104.  *         the DurationGauge are moved to the main panel.  But the
  105.  *         StatusMessage is removed.
  106.  * 14.     The EnableLocationChange and EnableSizeChange choice setting
  107.  *         are removed.  There are no longer such choices.
  108.  * 15.     Right now if a panel-item is selected and if another panel-item
  109.  *         is picked, the DeselectList() operation in the middle is
  110.  *         eliminated.  This operation involves updating of text fields and
  111.  *         messages and its removal speeds up the program.  The panel-list
  112.  *         must now take at least one choice.  (A choice must be selected
  113.  *         whenever there is at least one item on the list).  And now
  114.  *         there is no way to deselect a list by the user.
  115.  * 16.     The "modified bit" associated with the CurrentSelectionNumberLabel
  116.  *         is implemented.  Now, if a selection is picked, and if either
  117.  *         the quote window is moved or any text fields are changed, the
  118.  *         modified bit will be on.
  119.  * 17.     The Show-text-window button and the Show-quote-window-specifications-popup
  120.  *         button are removed.  They are now menu options under the Options Menu.
  121.  * 18.     The Modify button has its name changed to "Update Edit".
  122.  * 
  123.  * Revision 1.35  91/08/26  12:10:24  derek
  124.  * The following things are done:
  125.  * 1.    I have added a few notice_prompts to the linkProtocol (network)
  126.  *     functions to give warnings about invalid document names.
  127.  * 2.    The quoted text window will by default be hidden during "blank"
  128.  *     times. ie. when it is not displaying any text.  The interface has
  129.  *     been changed so that it now has a HideQuotedTExtWindowAfterPreview
  130.  *     check box.  The QuotedTextWindow will either stay on the screen
  131.  *     or be hidden as the author desires.
  132.  * 3.    Make the changes corresponding to the changing of name from OpenPanel
  133.  *     to Browse.
  134.  * 4.    The return value bug for OpenHandler, SaveHandler is fixed.
  135.  * 5.    I have changed the code so that Save and SaveAs will behave correctly.
  136.  *     The SaveAs PopUp/Open PopUp are removed.  Browse check is 
  137.  *     incorporated in the applications.
  138.  * 6.    The QuoteMaker file format has been changed.  An EditNumber field    
  139.  *     has been added.
  140.  * 7.    Changes corresponding to the return value by OpenDoc and SetSelection
  141.  *     are made.
  142.  * 8.    GetAppIcon() has been implemented.
  143.  * 9.    Fonts specified in the Edit-list will be preloaded in OpenDoc().
  144.  *     This will hopefully eliminate the startup delay needed to load
  145.  *     the font when we put text onto the Quoted TExt Window for the 
  146.  *     first time.
  147.  * 10.    The "play" button will now play things specified in the 
  148.  *     QuotedTExtWindowSpecificationsPopUp (instead of those specified
  149.  *     in the editList).
  150.  * 11.    The show selection button is replaced by the set selection button.
  151.  *     The Set Selection button willl now not only set the current
  152.  *     edit parameters but will also highlight the corresponding section
  153.  *     in the text.  Also, when one item on the panel-list is clicked on,
  154.  *     the corresponding segment in the text will also be highlighted.
  155.  * 12.    Notify events which tells the app to show the size and location 
  156.  *     of the Quoted Text Window are set up.  ie. those text-fields
  157.  *     on the interface will be updated instantaneously.
  158.  * 16.    editList.label is being sent across the network.
  159.  * 17.    The title bar and the footer of the QuotedTExtWindow are hidden.
  160.  * 
  161.  * Revision 1.34  91/07/15  12:20:09  derek
  162.  * 1.      I have added font selection panel to the application.
  163.  *         Now a user can specify a font by choosing a font family, a font
  164.  *         style and font size.
  165.  * 2.      Location and size fields are added to the application.  User
  166.  *         can specify the size and location of the QuotedTextWindow.
  167.  * 3.      A duration estimate button is added to estimate how long the
  168.  *         the quoted text should last.
  169.  * 4.      Interface has been redesigned to accomodate the addition of
  170.  *         font, size and location functionalities.
  171.  * 6.      EditList file format has been changed to accomodate the new
  172.  *         fields.  They are:  location (x,y), width, height, font family,
  173.  *         font style, font width for QuotedTextWindow.
  174.  * 5.      Two timers have been added in an attempt to ensure accuracy
  175.  *         of gauge-updating in the preview panel.
  176.  * 6.      Command line args are now supported.
  177.  * 7.      I have cleaned up the code by using saber.
  178.  * 8.      Several bugs from previous revision are fixed.
  179.  * 
  180.  * 
  181.  * Revision 1.33  91/07/02  15:07:56  derek
  182.  * QuoteMaker now fully speaks the new MAEstro protocol.
  183.  * 
  184.  * Revision 1.32  91/06/27  18:21:25  derek
  185.  * I have cleaned up some of the comments.  No change in code.
  186.  * 
  187.  * Revision 1.31  91/06/19  17:44:23  drapeau
  188.  * No changes; changing RCS revision numbers.
  189.  * 
  190.  * Revision 1.3  91/05/06  01:54:50  drapeau
  191.  * Using new version of RCS for this module; no other changes have been made.
  192.  * 
  193.  * Revision 1.2  91/01/06  20:19:31  drapeau
  194.  * Cosmetic, programming style changes made.  Nothing that changes the semantics
  195.  * of the code.
  196.  * 
  197.  * Revision 1.1  90/12/04  17:22:00  drapeau
  198.  * Initial revision
  199.  *  */
  200.  
  201. static char rcsid[] = "$Header: /Source/Media/collab/QuoteMaker/RCS/selectionUtils.c,v 2.11 92/05/14 15:42:36 drapeau Exp $";
  202.  
  203. /* ----------------------------------------------------------------------------
  204.    selectionUtils.c
  205.    
  206.    part of
  207.    
  208.    QuoteMaker
  209.    
  210.    A Text annotation application
  211.    for use with the Link Editor Multimedia Authoring Enviornment
  212.    
  213.    
  214.    developed by George Drapeau and Al Sargent
  215.    
  216.    Copyright (c) 1990 Academic Information Resources, Stanford University,
  217.    and Sun Microsystems, Inc.
  218.    
  219.    for more info, contact drapeau@jessica.stanford.edu
  220.    
  221.    
  222.    
  223.    
  224.    Last Modified:
  225.    October 31, 1990
  226.    */
  227.  
  228. #include <stdio.h>
  229. #include <sys/param.h>
  230. #include <sys/types.h>
  231. #include <xview/xview.h>
  232. #include <xview/font.h>
  233. #include <xview/panel.h>
  234. #include <xview/textsw.h>
  235. #include <xview/xv_xrect.h>
  236. #include <xview/server.h>          
  237. #include <xview/seln.h>            
  238. #include "QuoteMaker_ui.h"
  239.  
  240. #include <sys/stat.h>
  241. #include <xview/notice.h>
  242. #include <xview/notify.h>
  243.  
  244. #define _selection_c_
  245. #include "quoteMakerDefs.h"
  246.  
  247.  
  248. /* ----------------------------------------------------------------------------
  249.    Utilities: Textwindow stuff
  250.    */
  251.  
  252. void UnHighlightSelection()
  253.   textsw_set_selection(QuoteMaker_textWindowPopup->mainTextPane, 0, 0, PRIMARY_SELECTION);
  254.   textWindowStart = 0;
  255.   textWindowEnd   = 0;
  256. }
  257.  
  258.  
  259. void HighlightSelection (start, end)
  260.      int start;
  261.      int end;
  262. {
  263.   if (start < end + 1)
  264.   {
  265.     textsw_normalize_view (QuoteMaker_textWindowPopup->mainTextPane,
  266.                (Textsw_index) start);
  267.     textsw_set_selection (QuoteMaker_textWindowPopup->mainTextPane, start, end + 1, PRIMARY_SELECTION);
  268.   }
  269. }
  270.  
  271.  
  272. void GetSelectionEndpoints(start, end)
  273.      int* start;
  274.      int* end;
  275. {
  276.   Textsw_index first, last;
  277.   Seln_holder holder;
  278.   Seln_request *response;
  279.   register char *ptr;
  280.   
  281.   holder = selection_inquire (server, SELN_PRIMARY);
  282.   if (seln_holder_same_client (&holder, QuoteMaker_textWindowPopup->mainTextPane))
  283.   {
  284.     response = selection_ask (server, &holder,
  285.                   SELN_REQ_FIRST, NULL,
  286.                   SELN_REQ_LAST,  NULL,
  287.                   SELN_REQ_CONTENTS_ASCII, NULL,
  288.                   SELN_REQ_FAKE_LEVEL, SELN_LEVEL_LINE,
  289.                   SELN_REQ_FIRST_UNIT, NULL,
  290.                   SELN_REQ_LAST_UNIT, NULL,
  291.                   NULL);
  292.     ptr = response->data;
  293.     first = *(Textsw_index *) (ptr += sizeof (SELN_REQ_FIRST));
  294.     ptr += sizeof (Textsw_index);
  295.     last = *(Textsw_index *) (ptr += sizeof (SELN_REQ_LAST));
  296.     if (first > last)
  297.     {
  298.       *start = 0;
  299.       *end = 0;
  300.     }
  301.     else
  302.     {
  303.       *start = (int) first;
  304.       *end = (int) last;
  305.     }
  306.   }
  307.   else
  308.   {
  309.     *start = 0;
  310.     *end = 0;
  311.   }
  312. }                                    /* end function GetSelectionEndpoints */
  313.